<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 	xmlns="http://www.w3.org/1999/xhtml"
		xmlns:ui="http://java.sun.com/jsf/facelets"
		xmlns:h="http://java.sun.com/jsf/html"
		xmlns:f="http://java.sun.com/jsf/core"
		xmlns:c="http://java.sun.com/jsp/jstl/core"
		xmlns:p="http://primefaces.org/ui"
		xmlns:ec="http://www.b2cexpress.com.br/ecommerce"
		xmlns:s="http://www.suricattus.com.br/jsf/ui"
		xmlns:sf="http://www.suricattus.com.br/jsf/fn">

<ui:composition>

	<h:panelGroup id="#{id}">
		<p:commandLink id="#{id}modalDialogButton" action="#{pesquisarItemController.initPesquisa(grupo)}" 
				oncomplete="#{widgetVarDialog}.show();" type="button" styleClass="btn btn-primary" 
				process="@this" update="#{id}_Modal" style="#{styleButton}" >
			<h:panelGroup rendered="#{sf:getDefaultValue(showButtonIcon, true)}">
				<i class="#{icon ne null ? icon : 'icon-plus icon-white'}" />
			</h:panelGroup>
			<h:outputText value="#{labelButton eq null ? labels['botao.adicionar.itens'] : labelButton}" />
		</p:commandLink>
		
		<p:dialog id="#{id}_Modal" header="#{headerDialog}" widgetVar="#{widgetVarDialog}" modal="true" dynamic="true"
				resizable="false" minimizable="false" height="470">
		    <div class="row">
				<div class="span9">
					<ec:field id="#{id}titulo" fieldId="#{id}tituloField" label="#{labels['label.titulo']}" required="false">
						<p:inputText id="#{id}tituloField" value="#{pesquisarItemController.titulo}" label="#{labels['label.titulo']}"/>
					</ec:field>
					<ec:field id="#{id}grupo" fieldId="#{id}grupogrupoField" label="#{labels['label.grupo']}" required="false" rendered="#{sf:getDefaultValue(showGrupo, true)}">
						<h:selectOneMenu id="#{id}grupoField" value="#{pesquisarItemController.grupo}" converter="entityConverter" 
								label="#{labels['label.grupoProduto']}" hideNoSelectionOption="false">
							<f:selectItem itemLabel="#{labels['label.selecione']}" noSelectionOption="true" />
							<f:selectItems value="#{utilFactory.listaGrupoProduto}" var="_grupo" itemLabel="#{_grupo.nome}" itemValue="#{_grupo}" />
						</h:selectOneMenu>
					</ec:field>
				</div>
			</div>
			<div class="row">
				<div class="form-actions">
					<p:commandLink action="#{pesquisarItemController.pesquisar(lista,item)}" update="#{id}result"  process="#{id}"
							styleClass="btn btn-primary" style="margin-right: 10px !important;" oncomplete="#{id}table.getPaginator().setPage(0)">
						<h:outputText value="#{labels['botao.pesquisar']}" />
						<f:setPropertyActionListener target="#{pesquisarItemController.tipoItem}" value="#{tipoItem}" />
					</p:commandLink>
					<p:commandLink onclick="#{widgetVarDialog}.hide();" type="button" styleClass="btn btn-primary">
						<h:outputText value="#{labels['botao.cancelar']}" />
					</p:commandLink>  
				</div>
			</div>
			<br />
			<h:panelGroup id="#{id}result">
				<p:dataTable id="#{id}table" value="#{pesquisarItemController.itens}" var="_itemPesquisa" styleClass="table table-striped table-hover"
						rendered="#{pesquisarItemController.itens ne null and not empty pesquisarItemController.itens}" 
						rows="3" paginator="true" paginatorPosition="bottom" paginatorAlwaysVisible="false" 
						emptyMessage="#{messages['msgP006']}" widgetVar="#{id}table">
					<p:column>
						<f:facet name="header">
							<h:outputText value="#{labels['label.titulo']}" />
						</f:facet>
						<h:outputText value="#{_itemPesquisa.titulo}" />
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="#{labels['label.status']}" />
						</f:facet>
						<h:outputText value="#{labels[_itemPesquisa.statusItem.codigo]}" />
					</p:column>
					<p:column>
						<ui:insert />
					</p:column>
				</p:dataTable>
				<h:outputText value="#{messages['msgP006']}" rendered="#{pesquisarItemController.itens ne null and empty pesquisarItemController.itens}" />
			</h:panelGroup>
		</p:dialog> 
	</h:panelGroup>
	
</ui:composition>
</html>
